{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 评估函数预训练网络 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From D:\\anaconda3\\lib\\site-packages\\tensorflow\\python\\compat\\v2_compat.py:96: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "non-resource variables are not supported in the long term\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import tensorflow.compat.v1 as tf\n",
    "tf.disable_v2_behavior()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from conv import conv_net\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义训练、测试数据集路径"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_path = \"C:/Users/王欣哲/Desktop/codes/人工智能基础/问题3 进化学习/dataset\"\n",
    "test_path = \"C:/Users/王欣哲/Desktop/codes/人工智能基础/问题3 进化学习/dataset\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义执行器    使用GPU运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "gpu_options = tf.GPUOptions(allow_growth=True)\n",
    "gpu_options =tf.GPUOptions(per_process_gpu_memory_fraction=0.8,allow_growth=True) ##每个gpu占用0.8的显存\n",
    "config=tf.ConfigProto(gpu_options=gpu_options,allow_soft_placement=True,log_device_placement=False)\n",
    "sess=tf.Session(config=config)##如果电脑有多个GPU，tensorflow默认全部使用。如果想只使用部分GPU，可以设置CUDA_VISIBLE_DEVICES。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "加载数据集 定义batch获取函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 加载 训练集 标签\n",
    "with open(train_path + \"/train.csv\") as f:\n",
    "    train_data = np.loadtxt(f,delimiter=',') \n",
    "    train_len = len(train_data)\n",
    "# 加载 测试集 标签\n",
    "with open(test_path + \"/test.csv\") as f:\n",
    "    test_data = np.loadtxt(f,delimiter=',') \n",
    "    test_len = len(test_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "#batch获取函数\n",
    "def get_train_batch(batch_size):\n",
    "    idx = np.random.randint(1,train_len,size=batch_size)\n",
    "    _chess=[]\n",
    "    _label=[]\n",
    "    for i in idx:\n",
    "        _chess.append(train_data[i,0:225])\n",
    "        _label.append(train_data[i,225])\n",
    "    _chess = np.asfarray(_chess)\n",
    "    _label = np.asfarray(_label).reshape([batch_size,1])\n",
    "    return _chess,_label/1000000\n",
    "\n",
    "def get_test_batch(batch_size):\n",
    "    idx = np.random.randint(1,test_len,size=batch_size)\n",
    "    _chess=[]\n",
    "    _label=[]\n",
    "    for i in idx:\n",
    "        _chess.append(test_data[i,0:225])\n",
    "        _label.append(test_data[i,225])\n",
    "    _chess = np.asfarray(_chess)\n",
    "    _label = np.asfarray([_label]).reshape([batch_size,1])\n",
    "    return _chess,_label/1000000"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义神经网络"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "xs,ys,y = conv_net()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "#定义损失函数、优化器\n",
    "loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys-y), reduction_indices=[1]))\n",
    "train = tf.train.AdamOptimizer(1e-3).minimize(loss)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "变量初始化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "init = tf.global_variables_initializer()\n",
    "sess.run(init)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1, 225)\n",
      "(1, 1)\n",
      "[[8.e-06]]\n",
      "[[-273.7071]]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x1c00dad26a0>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAALu0lEQVR4nO3db6hk9X3H8fenu25TjalaMTG6jQoitLZUWcSkaSvYhK0R1wcNGJp2aQKLD0K1EJK1QvuwpCnpHygtYtNuQQwl0UREE0UC7YOsqFvXdbNGN9bqZlc3f4omzYNk6bcP5mx7mcy9e51zztzp/t4vuMyZOb+Z890z89nz584931QVkk5/P7XRBUhaDMMuNcKwS40w7FIjDLvUiM2LXFgST/1LI6uqzHrcLbvUCMMuNcKwS43oFfYk25N8I8nhJLuHKkrS8DLv12WTbAKeB94HHAGeAD5UVV9f4zmeoJNGNsYJumuAw1X1YlX9CPgcsKPH60kaUZ+wXwS8suL+ke4xSUuoz+/ZZ+0q/MRuepJdwK4ey5E0gD5hPwJsXXH/YuDo9KCqugu4CzxmlzZSn934J4DLk1yaZAtwC/DAMGVJGtrcW/aqOpHkY8BXgE3AZ6vq4GCVSRrU3L96m2th7sZLo/O78VLjDLvUCMMuNcKwS40w7FIjD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k9NMTvpMN+dY2PqZ8iFW2YVf5Dpa4QFgZze9E/jSjDHr+bwNIsl24JPATVX1w1XGrOf9Hc+izwgyOZv8PJOzpHd2j90K3NpNB/ibbv4BJte3G6uW9zLZrXsGeLr7uWGqno8BB5mcyd0LvGfEei7rlrO/W+aGrp8VdZ3JJLw/u+Kxha0jJv/JHAN+zGRr/VHg55hc+PSF7va8buw7gYfW+ryNVM9hJucHTn6O/m66ntXe30X9+HVZqRF+g05qhGGXGmHYpUYYdqkRhl1qhGGXGmHYpUb8D9fZ6IkCdtpFAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "batch = get_train_batch(1)\n",
    "print(batch[0].shape)\n",
    "print(batch[1].shape)\n",
    "print(batch[1])\n",
    "print(sess.run(y,feed_dict={xs:batch[0]}))\n",
    "plt.imshow(batch[0][0].reshape(15,15),cmap='Greys',interpolation='None')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "开始训练"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "res_train_loss = []\n",
    "res_test_loss = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    T:0    loss:2150.843506\n",
      "Test-set   T:0    loss:2056.007324\n",
      "    T:50    loss:1232.006226\n",
      "    T:100    loss:859.287598\n",
      "    T:150    loss:790.283386\n",
      "    T:200    loss:629.650085\n",
      "Test-set   T:200    loss:588.730652\n",
      "    T:250    loss:535.255737\n",
      "    T:300    loss:507.641296\n",
      "    T:350    loss:425.983215\n",
      "    T:400    loss:379.809845\n",
      "Test-set   T:400    loss:349.254669\n",
      "    T:450    loss:330.185028\n",
      "    T:500    loss:285.783325\n",
      "    T:550    loss:259.148926\n",
      "    T:600    loss:272.256714\n",
      "Test-set   T:600    loss:243.788544\n",
      "    T:650    loss:235.996063\n",
      "    T:700    loss:226.603592\n",
      "    T:750    loss:211.852463\n",
      "    T:800    loss:203.415192\n",
      "Test-set   T:800    loss:184.885986\n",
      "    T:850    loss:179.601700\n",
      "    T:900    loss:174.248550\n",
      "    T:950    loss:159.405823\n",
      "    T:1000    loss:160.654633\n",
      "Test-set   T:1000    loss:144.805283\n",
      "    T:1050    loss:148.088531\n",
      "    T:1100    loss:138.499451\n",
      "    T:1150    loss:137.633545\n",
      "    T:1200    loss:126.374527\n",
      "Test-set   T:1200    loss:119.966782\n",
      "    T:1250    loss:134.495178\n",
      "    T:1300    loss:113.763878\n",
      "    T:1350    loss:115.601303\n",
      "    T:1400    loss:127.644119\n",
      "Test-set   T:1400    loss:103.697899\n",
      "    T:1450    loss:105.502937\n",
      "    T:1500    loss:110.752182\n",
      "    T:1550    loss:98.770988\n",
      "    T:1600    loss:95.594269\n",
      "Test-set   T:1600    loss:91.156784\n",
      "    T:1650    loss:99.670937\n",
      "    T:1700    loss:90.121979\n",
      "    T:1750    loss:93.564659\n",
      "    T:1800    loss:84.522369\n",
      "Test-set   T:1800    loss:80.388176\n",
      "    T:1850    loss:79.305908\n",
      "    T:1900    loss:78.276939\n",
      "    T:1950    loss:75.728958\n",
      "    T:2000    loss:77.105965\n",
      "Test-set   T:2000    loss:72.774208\n",
      "    T:2050    loss:80.285255\n",
      "    T:2100    loss:75.351738\n",
      "    T:2150    loss:73.592659\n",
      "    T:2200    loss:67.386383\n",
      "Test-set   T:2200    loss:67.326057\n",
      "    T:2250    loss:66.234337\n",
      "    T:2300    loss:67.204697\n",
      "    T:2350    loss:61.477840\n",
      "    T:2400    loss:68.084526\n",
      "Test-set   T:2400    loss:62.367710\n",
      "    T:2450    loss:60.835281\n",
      "    T:2500    loss:64.797371\n",
      "    T:2550    loss:59.873070\n",
      "    T:2600    loss:64.652588\n",
      "Test-set   T:2600    loss:58.676586\n",
      "    T:2650    loss:60.346020\n",
      "    T:2700    loss:58.592216\n",
      "    T:2750    loss:59.782707\n",
      "    T:2800    loss:54.734570\n",
      "Test-set   T:2800    loss:55.873520\n",
      "    T:2850    loss:60.533779\n",
      "    T:2900    loss:60.743843\n",
      "    T:2950    loss:52.214912\n",
      "    T:3000    loss:48.522816\n",
      "Test-set   T:3000    loss:52.517326\n",
      "    T:3050    loss:52.855289\n",
      "    T:3100    loss:50.595474\n",
      "    T:3150    loss:49.719109\n",
      "    T:3200    loss:50.390556\n",
      "Test-set   T:3200    loss:49.610218\n",
      "    T:3250    loss:49.953091\n",
      "    T:3300    loss:47.551945\n",
      "    T:3350    loss:45.433807\n",
      "    T:3400    loss:47.343372\n",
      "Test-set   T:3400    loss:50.258419\n",
      "    T:3450    loss:48.890469\n",
      "    T:3500    loss:43.980347\n",
      "    T:3550    loss:47.807983\n",
      "    T:3600    loss:44.919781\n",
      "Test-set   T:3600    loss:45.673359\n",
      "    T:3650    loss:44.119682\n",
      "    T:3700    loss:45.552788\n",
      "    T:3750    loss:44.812195\n",
      "    T:3800    loss:40.141861\n",
      "Test-set   T:3800    loss:43.940289\n",
      "    T:3850    loss:43.089314\n",
      "    T:3900    loss:44.409935\n",
      "    T:3950    loss:45.814232\n",
      "    T:4000    loss:40.656925\n",
      "Test-set   T:4000    loss:41.822712\n",
      "    T:4050    loss:43.040146\n",
      "    T:4100    loss:42.850876\n",
      "    T:4150    loss:42.008251\n",
      "    T:4200    loss:43.243591\n",
      "Test-set   T:4200    loss:40.650169\n",
      "    T:4250    loss:41.267822\n",
      "    T:4300    loss:38.657066\n",
      "    T:4350    loss:39.904808\n",
      "    T:4400    loss:39.187832\n",
      "Test-set   T:4400    loss:39.304619\n",
      "    T:4450    loss:39.221474\n",
      "    T:4500    loss:43.430691\n",
      "    T:4550    loss:38.265419\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-17-056cf25cbf7c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mbatch_test\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mget_test_batch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1000\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m10000\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m     \u001b[0mbatch\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mget_train_batch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mBATCH_SIZE\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m     \u001b[0msess\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtrain\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mfeed_dict\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[0mxs\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0mbatch\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mys\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0mbatch\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mi\u001b[0m\u001b[1;33m%\u001b[0m\u001b[1;36m50\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m<ipython-input-15-95695a15424a>\u001b[0m in \u001b[0;36mget_train_batch\u001b[1;34m(batch_size)\u001b[0m\n\u001b[0;32m      7\u001b[0m         \u001b[0m_chess\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtrain_data\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m225\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      8\u001b[0m         \u001b[0m_label\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtrain_data\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m225\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 9\u001b[1;33m     \u001b[0m_chess\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0masfarray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0m_chess\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     10\u001b[0m     \u001b[0m_label\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0masfarray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0m_label\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mbatch_size\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     11\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0m_chess\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0m_label\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m1000000\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m<__array_function__ internals>\u001b[0m in \u001b[0;36masfarray\u001b[1;34m(*args, **kwargs)\u001b[0m\n",
      "\u001b[1;32mD:\\anaconda3\\lib\\site-packages\\numpy\\lib\\type_check.py\u001b[0m in \u001b[0;36masfarray\u001b[1;34m(a, dtype)\u001b[0m\n\u001b[0;32m    113\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0m_nx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0missubdtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdtype\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0m_nx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minexact\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    114\u001b[0m         \u001b[0mdtype\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_nx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfloat_\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 115\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[0masarray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdtype\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    116\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    117\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\anaconda3\\lib\\site-packages\\numpy\\core\\_asarray.py\u001b[0m in \u001b[0;36masarray\u001b[1;34m(a, dtype, order)\u001b[0m\n\u001b[0;32m     83\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     84\u001b[0m     \"\"\"\n\u001b[1;32m---> 85\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0morder\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0morder\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     86\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     87\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "BATCH_SIZE=1024\n",
    "batch_test = get_test_batch(1000)\n",
    "for i in range(10000):\n",
    "    batch = get_train_batch(BATCH_SIZE)\n",
    "    sess.run(train,feed_dict = {xs:batch[0],ys:batch[1]})\n",
    "    if i%50==0:\n",
    "        l = sess.run(loss,feed_dict = {xs:batch[0],ys:batch[1]})\n",
    "        res_train_loss.append(l)\n",
    "        print(\"    T:%d    loss:%f\" %(i,l))\n",
    "    if i%200==0:\n",
    "        l = sess.run(loss,feed_dict = {xs:batch_test[0],ys:batch_test[1]})\n",
    "        res_test_loss.append(l)\n",
    "        print(\"Test-set   T:%d    loss:%f\" %(i,l))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "打印训练曲线"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "92\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEICAYAAACzliQjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3deZScdZ3v8fe39uo96XSH0NkhGgKyRkAUB3VUcIOZkRGug4yONxwO49XRO14Z5w4zcw+O9x5HR3TwiILgcUHcBkbcEFRkQLEJSwwhEEhCOukk3Ul67671e/94nu5Uks7e6Urq+bzOqdNVv3qeqm89hE899X02c3dERCQaYtUuQEREpo9CX0QkQhT6IiIRotAXEYkQhb6ISIQo9EVEIkShL5FgZj8xs2urXcfezMzN7NRq1yHRkah2ASL7Y2ZDFQ/rgBxQCh9f5+7fPNTXcvfLprK2Q2FmdwJd7v730/3eIvuj0Jfjlrs3jN83sw3AB939F3tPZ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MxyqOmevoiI7KnW1/RFRKSCQl9EJEJqMvTN7FIzW2tm68zsE9WuZzqZ2Twz+6WZrTGz1Wb24XB8ppk9YGYvhH9nVLvW6WJmcTN70sx+FD6O5LIwsxYz+56ZPRf++3hNhJfF34T/f/zBzL5tZpmoLIuaC/3w6lz/DlwGLAOuNrNl1a1qWhWBj7n7acCFwA3h5/8E8KC7LwEeDB9HxYeBNRWPo7osPg/81N2XAmcRLJPILQsz6wD+B7Dc3c8gOA/YVURkWdRc6BPxq3O5e7e7rwzvDxL8j91BsAzuCie7C7iiOhVOLzObC7wd+GrFcOSWhZk1Aa8Hbgdw97y79xHBZRFKAFkzSwB1BKd4j8SyqMXQP6Src0WBmS0EzgF+B8x2924IvhiA9upVNq3+Dfg4UK4Yi+KyWAz0AF8LW11fNbN6Irgs3H0z8BngZaAb6Hf3nxORZVGLoX9IV+eqdWbWAHwf+Ii7D1S7nmows3cA2939iWrXchxIAOcCX3L3c4BharR9cTBhr/5yYBFwMlBvZn9R3aqmTy2GfuSvzmVmSYLA/6a7/yAc3mZmc8Ln5wDbq1XfNHot8C4z20DQ5nujmX2DaC6LLqDL3X8XPv4ewZdAFJfFHwPr3b3H3QvAD4CLiMiyqMXQj/TVuczMCPq2a9z9sxVP3QdcG96/Frh3umubbu5+o7vPdfeFBP8OHnL3vyCay2IrsMnMXhkOvQl4lgguC4K2zoVmVhf+//Imgm1fkVgWNXlErpm9jaCXO351rpurXNK0MbPXAb8BVrG7j/13BH39e4D5BP/or3T3nVUpsgrM7BLgf7r7O8yslQguCzM7m2CDdgp4CXg/wYpfFJfFPwHvIdjb7Ungg4J+IhMAAAA6SURBVEADEVgWNRn6IiIyuVps74iIyH4o9EVEIkShLyISIQp9EZEIUeiLiESIQl9EJEIU+iIiEfL/AXEDTNB48m2RAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(len(res_train_loss))\n",
    "plt.plot(res_train_loss)\n",
    "plt.title(\"Train-set loss\")\n",
    "plt.savefig(\"./train_loss_60.jpg\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "23\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEICAYAAACzliQjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3de5hddX3v8fdnz57ZM8nsSQLZEyAJFyVBA9UoOYiKFI9aEa1gqzYcK/S0PVELfUprn9bL6SM950n1qbUePB6wqBzRKpTWKsGDLRcr0JaLA41yDQn3IQOZJEBmcpnb/p4/1tqZnWRPZjIzmZ3Z6/N6nv3stX/r9stm+Ky1f2ut308RgZmZZUOu3hUwM7OZ49A3M8sQh76ZWYY49M3MMsShb2aWIQ59M7MMceibzTBJ50jqrnc9LJsc+jYrSOqvepUl7a76/JFJbO+nkn73MNX1aUnvPBzbNpuqfL0rYDYREdFemZb0NPC7EXFb/WpkNjv5TN9mNUk5SZ+S9ISkbZJukHRUOq9V0t+m5S9L+pmkRZLWAm8Dvpr+UvjqGNs+T9IjkvokPS/pj6vmvU/S+nS7/y7pdWn5d4DjgZvSbf/JBP4Nr01/ebws6WFJ7x+vDpIWSvpRus52SXdJ8v/PNr6I8MuvWfUCngbemU5fBtwDLAEKwN8A16XzPgbcBMwBmoDTgY503k9Jfi0cbD89wNvS6QXAG9PpNwJbgDel2704rVNh//qNsd1zgO50uhnYBHwGaAH+M9AHnDJOHT4PfC1dv5nkIKZ6/7fx68h/+czAZruPAZ+NiO6IGAAuBz4oKQ8MAUcDJ0fESETcHxE7DmHbQ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jhSXSvpF2vwz65oxpoukE4E3APfSAH8rjRj6ExqoJaPeGhFvJGn6ukTS2fWukB2xrgJeDawEeoAv1bc69SGpHfg+cFlE7Kh3faZDI4a+B2oZQ0RsTt+3AD8gaQozeFHSsQDp+5Y616fuIuLFiBiJiDLwdTL4tyKpmSTwvxsR/5gWz/q/lUYMfQ/UUoOkuZKKlWngV4CHDr5WZqwDLk6nLwZurGNdjgiVYEt9gIz9rUgS8E3g0Yj466pZs/5vpSGfyE1vL/tfjA7UsrbOVao7Sa8iObuHZByF72Xxe5F0HXAOSRe5LwKfA34I3AAcDzwLfCgiMnNhc4zv5BySpp0AngY+VmnLzgJJZwF3AQ8C5bT4MyTt+rP6b6UhQ9/MzGprxOYdMzMbg0PfzCxDHPpmZhni0DczyxCHvplZhjj0zcwyxKFvZpYh/x/sHSnYJdGV7wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(len(res_test_loss))\n",
    "plt.plot(res_test_loss)\n",
    "plt.title(\"T-set loss\")\n",
    "plt.savefig(\"C:/Users/王欣哲/Desktop/codes/人工智能基础/问题1 棋盘识别/2.模型训练/test_loss_60.jpg\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "保存训练模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'./ass_net_3.0/conv_ver_1.ckpt'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "saver = tf.train.Saver()#为下面保存做准备\n",
    "saver.save(sess, './ass_net_3.0/conv_ver_1.ckpt')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From <ipython-input-21-501c48cfef1f>:2: convert_variables_to_constants (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use `tf.compat.v1.graph_util.convert_variables_to_constants`\n",
      "WARNING:tensorflow:From D:\\anaconda3\\lib\\site-packages\\tensorflow\\python\\framework\\convert_to_constants.py:854: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use `tf.compat.v1.graph_util.extract_sub_graph`\n",
      "WARNING:tensorflow:From <ipython-input-21-501c48cfef1f>:4: FastGFile.__init__ (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use tf.gfile.GFile.\n"
     ]
    }
   ],
   "source": [
    "#保存为pb文件，更小，更好\n",
    "constant_graph = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, ['y'])\n",
    "\n",
    "with tf.gfile.FastGFile('./ass_net_V3.0.pb', mode='wb') as f:\n",
    "    f.write(constant_graph.SerializeToString())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "batch = get_train_batch(500)\n",
    "print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
